Promise.prototype._finally = function (cb) {
  cb = typeof cb !== "function" ? function () {} : cb;

  const Fn = this.prototype;

  function onFullfilled(data) {
    return Fn.resolve(cb()).then(() => {
      return data;
    });
  }
  function onRejected(reason) {
    return Fn.rejected(cb()).then(() => {
      return reason;
    });
  }

  Fn.then(onFullfilled, onRejected);
};
